// 抽象类 - 不能被实例化
abstract class PublicCar {
  name: string; // 车的品牌
  number: string; // 车牌号
  abstract price: number; // 抽象属性（必须被子类重写）
  constructor(name: string, number: string) {
    this.name = name;
    this.number = number;
  }
}
// 普通车
class ExpressCar extends PublicCar {
  public price = 1.5;
  constructor(name: string, number: string) {
    super(name, number);
  }
}
// 特殊车
class SpecialCar extends PublicCar {
  public price = 5;
  constructor(name, number) {
    super(name, number);
  }
}

// 行程
class Trip {
  car: PublicCar;
  constructor(car: PublicCar) {
    this.car = car;
  }
  start() {
    console.log(`行程开始：name ${this.car.name} ~ number ${this.car.number}`);
  }
  end(kilometer: number) {
    console.log(`价格 ${this.car.price * kilometer}`);
  }
}

const car = new ExpressCar("奔驰", "川A25500");
const trip = new Trip(car);
trip.start();
trip.end(5);
